<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ include file="../../common/taglibs.jsp" %>
<c:set var="bashPath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <script type="text/javascript" src="lib/PIE_IE678.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.7/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="lib/icheck/icheck.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/zTree/css/zTreeStyle/zTreeStyle.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>部门管理</title>
    <style type="text/css">
        .ztree li span.button{z-index: 999}
        .ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
    </style>
    <script>
        var bathPath = '${pageContext.request.contextPath}';
    </script>

</head>
<div >

</div>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 部门机构管理 <span class="c-gray en">&gt;
</span>
    部门列表
    <c:if test="${user.type =='3'}">
    <span class="">切换当前域名:
    <select  name="domain" id="pdomain">
            <c:forEach items="${domainList}" var="domain">
                <option value="${domain.domain_name}" <c:if test="${dom==domain.domain_name}">selected</c:if>>${domain.domain_name}</option>
            </c:forEach>
    </select>
    </span>
    </c:if>
    <c:if test="${ user.type=='2'}">
        <input type="hidden" name="domain" id="pdomain" value="${user.domain}">
    </c:if>
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>




<%--<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 部门机构管理 <span class="c-gray en">&gt;</span> 部门列表 <span class="">域:--%>
    <%--<select  id="pdomain">--%>
        <%--<c:if test="${user.type!='1'}">--%>
            <%--<c:forEach items="${domainList}" var="domain">--%>
                <%--<option value="${domain.domain_name}" <c:if test="${domain.domain_name eq user.domain or domain.domain_name eq dom}">selected</c:if> >${domain.domain_name}</option>--%>
            <%--</c:forEach>--%>
        <%--</c:if>--%>
    <%--</select>--%>
<%--</span><a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>--%>

<div>


    <div class="zhu-div-left zTreeDemoBackground left " style="float: left">
        <ul id="tree" class="ztree"></ul>

    </div>
    <div class="page-container zhu-div-right"  style="float: right">

        <form class="form form-horizontal" id="form-quota-group-search" >
            <div class="text-c">
                <input type="text" class="input-text" style="width:250px" placeholder="输入企业成员" id="" name="name" value="${usersBo.name}">
                <button type="submit" class="btn btn-success radius" id="quotaGroupSearch" name=""><i class="Hui-iconfont">&#xe665;</i> 搜人员</button>
            </div>
        </form>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            <a href="javascript:;" onclick="member_add('添加企业成员','group_users_add.htmlx','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加企业成员</a>
        </span>
        </div>
        <div class="mt-20">
            <form class="form form-horizontal" id="form-quota-group" >
                <table id="tableGroup" class="table table-border table-bordered table-bg table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="25"><input type="checkbox" name="" value=""></th>
                        <th width="200">邮箱</th>
                        <th width="100">域名</th>
                        <th width="100">姓名</th>
                        <th width="90">联系电话</th>
                        <th width="150">地址</th>
                        <th width="150">工号</th>
                        <th width="100">操作</th>
                    </tr>
                    </thead>
                    <%--<tbody>--%>
                    <%----%>
                    <%--</tbody>--%>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<%--<script type="text/javascript" src="static/js/jquery-3.2.1.js"></script>--%>
<%--<script type="text/javascript" src="static/zTree/js/jquery-1.4.4.min.js"></script>--%>
<script type="text/javascript" src="static/zTree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="static/zTree/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="static/zTree/js/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="static/zTree/userJS/group.js"></script>

<script>
    function loadTable(url) {
        table = $('#tableGroup').dataTable({
            ajax:{
                url:url,
                "dataSrc": "tableData"
            },
            "order": [[1, 'asc']],
            "columns":[
                {data:"id"},
                {data:"user_name"},
                {data:"domain"},
                {data:"name"},
                {data:"telephone"},
                {data:"address"},
                {data:"work_no"},
                {data:null}

            ],
            "columnDefs":[
                {
                    targets:0,
                    render:function (a,b,c,d) {
                        return "<input type=checkbox name=ids value="+a+">";
                    }
                },

                {
                    targets:-1,
                    render:function (a,b,c,d) {
                        var html = ' \
                    <a title="编辑" href="javascript:;" onclick="member_edit(\'用户编辑\',\'group_users_add.htmlx\',\''+c.id+'\',\'800\',\'500\')" class="ml-5" style="text-decoration:none">\
                            <i class="Hui-iconfont">&#xe6df;</i></a>\
                    <a style="text-decoration:none" class="ml-5" onClick="change_password(\'修改密码\',\'users-change-password.htmlx\',\''+c.id+'\',\'600\',\'270\')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>\
                    <a title="删除" href="javascript:;" onclick="member_del(this,\''+c.id+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
                        return html;
                    }
                }

            ],
            language: {
                // lengthMenu: '<select class="form-control input-xsmall">' + '<option value="1">1</option>' + '<option value="10">10</option>' + '<option value="20">20</option>' + '<option value="30">30</option>' + '<option value="40">40</option>' + '<option value="50">50</option>' + '</select>条记录',//左上角的分页大小显示。
                search: '<span class="am-text-xs">搜索：</span>',//右上角的搜索文本，可以写html标签
//
//            'paginate': {
//                'first':      '第一页',
//                'last':       '最后一页',
//                'next':       '',
//                'previous':   ''
//            },

                zeroRecords: "暂无记录",//table tbody内容为空时，tbody的内容。
                //下面三者构成了总体的左下角的内容。
                info: "总共_PAGES_ 页，显示第_START_ 到第 _END_条记录 ",//左下角的信息显示，大写的词为关键字。
                infoEmpty: "没有找到记录",//筛选为空时左下角的显示。
                infoFiltered: ""//筛选之后的左下角筛选提示，
            },
            paging: true,
            pagingType: "full",//分页样式的类型
            "displayLength": 10,
            initComplete: function (settings, json) {
                //$("#txlCount").text(json.count);


            }

        });
    }






    var url = "${pageContext.request.contextPath}/queryGroupByDomain.htmlx?domain="+$("#pdomain").val();
    var setting = {
        async: {
            enable: true,
            url:url,
            autoParam:["id", "name=n", "level=lv"],
            dataFilter: filter
        },
        view: {expandSpeed:"",
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom,
            selectedMulti: false
        },
        edit: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeRemove: beforeRemove,
            beforeRename: beforeRename,
            onRemove:remove,
            onClick:zTreeOnclick,
            onRename:rename
        }
    };


    var table;

    var flat = false;
    <%--function getTree() {--%>
    <%--// Some logic to retrieve, or generate tree structure--%>
    <%--var url = "${pageContext.request.contextPath}/users-group-list.htmlx";--%>
    <%--$.get(url,"",function (data) {--%>
    <%--console.log(data);--%>
    <%--$.fn.zTree.init($("#tree"), setting, data);--%>
    <%--},'json');--%>
    <%--}--%>
    $(function () {
        //  getTree();
        $.fn.zTree.init($("#tree"), setting);
        $("#pdomain").on('change',function () {
            location.href=bathPath+"/group_list.htmlx?domain="+$(this).val();
        });
        // $("#selectAll").bind("click", selectAll);
    });

    function zTreeOnclick(event, treeId, treeNode) {
        var id = treeNode.id;
        var url = bathPath+"/queryGroupMembers.htmlx?groupId="+id;
        if(!flat){
            loadTable(url);
            flat = true;
        }else{
            table.api().ajax.url(url).load();
        }

    }
</script>
<script type="text/javascript">
    /*用户-添加*/
    function member_add(title,url,w,h){
        var domain = $("#pdomain").val();
        url = url+"?domain="+domain;
        layer_show(title,url,w,h);
    }
    function datadel(){
        $.ajax({
            url: "deleteUser.htmlx",
            type:"POST",
            data:$("#form-quota-group").serializeArray(),
            success: function(data){
                location.reload()
                layer.msg('操作成功!',{icon: 1,time:1000});
            },
            error: function(data){
                layer.msg('操作失败!请联系系统管理员!',{icon: 5,time:1000});
            }
        })
    }
    function member_start(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            $.ajax({
                url: "startUser.htmlx",
                type:"POST",
                data:{id:id},
                success: function(data){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                    $(obj).remove();
                    layer.msg('已启用!',{icon: 6,time:1000});
                },
                error: function(data){
                    layer.msg('操作失败!请联系系统管理员!',{icon: 5,time:1000});
                }
            })

        });
    }
    /*用户-编辑*/
    function member_edit(title,url,id,w,h){
        url=url+"?id="+id;
        layer_show(title,url,w,h);
    }
    /*密码-修改*/
    function change_password(title,url,id,w,h){
        url=url+"?id="+id;
        layer_show(title,url,w,h);
    }
    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url: "deleteUser.htmlx",
                type:"POST",
                data:{ids:id},
                success: function(data){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                },
                error: function(data){
                    layer.msg('操作失败!请联系系统管理员!',{icon: 5,time:1000});
                }
            })
        });
    }
</script>
</body>

</html>